package com.puman.watchtrade.util;
import android.app.Activity;
import android.os.Environment;

public class Util {
   public static final int DELAY = 5000; //延时5000ms
   public static final int LOAD_IMG = 0x01;
   private static Util util;  
   public static int flag = 0;  
   private Util(){  
         
   }  
     
   public static Util getInstance(){  
       if(util == null){  
           util = new Util();  
       }  
       return util;  
   }  
     
   /** 
    * @return 
    */  
   public boolean hasSDCard(){  
       boolean b = false;  
       if(Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())){  
           b = true;  
       }  
       return b;  
   }  
     
   /** 
    * @return 
    */  
   public String getExtPath(){  
       String path = "";  
       if(hasSDCard()){  
           path = Environment.getExternalStorageDirectory().getPath();  
       }  
       return path;  
   }  
     
   /** 
    * @param mActivity 
    * @return 
    */  
   public String getPackagePath(Activity mActivity){  
       return mActivity.getFilesDir().toString();  
   }  
 
   /** 	    
    * @param url 
    * @return 
    */  
   public String getImageName(String url) {  
       String imageName = "";  
       if(url != null){  
	       String urlFileName = "";
	       String urlTest = "";
	       int indexPre = url.lastIndexOf("upload/")+"upload/".length();
	      
	       urlFileName = url.substring(url.lastIndexOf("/")+1);	
	       if(indexPre!=-1)
	         imageName = urlTest+urlFileName;
       }  
       return imageName;  
   }
}
